<template>
    <div class="events_list">
         <Banner></Banner>
         <mainContent catname="走访列表">
           <div slot="menu_list">
             <dl>
               <dt class="menu_dt" :style="{backgroundImage: 'url(' + this.$util.storage.get('menu_bg') + ')'}">走访列表</dt>
             </dl>
           </div>
           <div slot="inner_content" style="box-sizing: border-box;">
             <div class="event_detail">
               <div class="event_detail_list">

                    <div class="titles">
                         <div class="titles_left">
                             <span class="title_desc">走访人</span>
                             <span class="title_desc">事件类型</span>
                             <span class="title_desc">事件内容</span>
                         </div>
                         <div class="titles_right">
                             <span class="title_desc">事件状态</span>
                             <span class="title_desc">走访轨迹</span>
                             <span class="title_desc">走访日期</span>
                         </div>
                    </div>

                   <!--<NoData v-if="flag"></NoData>-->
                   <NoData v-if="list.length==0"></NoData>

                    <div  v-for="item in list" >

                        <div v-if="typeof item.ventList != 'undefined' && item.ventList.length > 0">

                          <div class="list_step" @click="CheckDetail(sub.id)" v-for="sub in item.ventList">

                            <div class="step_left">
                                 <span class="grid_name">{{name}}</span>
                                 <span class="event">
                                  <span v-if="sub.cat_id==2">普通事件</span>
                                  <span v-else-if="sub.cat_id==4" class="yes">重点事件</span>
                                 </span>
                                 <span class="content">{{sub.content}}</span>
                            </div>
                            <div class="step_right">

                                <span class="status no" v-if="sub.status == 0">未解决</span>
                                <span class="status yes" v-else-if="sub.status == 1">已解决</span>
                                <span class="status no" v-else-if="sub.status == 2">解决中</span>

                                <div class="guiji" @click.stop="CheckGuiji(item.id)"><div class="check_guiji">查看轨迹</div></div>
                                <span class="time">{{item.end_at}}</span>
                            </div>

                          </div>

                        </div>

                        <div class="list_step" v-else>
                          <div class="step_left">
                               <span class="grid_name">{{name}}</span>
                               <span class="event">-</span>
                               <span class="content">-</span>
                          </div>
                          <div class="step_right">
                              <span class="status">-</span>
                              <div class="guiji" @click.stop="CheckGuiji(item.id)"><div class="check_guiji">查看轨迹</div></div>
                              <span class="time">{{item.end_at}}</span>
                          </div>
                        </div>

                    </div>



               </div>

             </div>
           </div>
         </mainContent>
         <MainMenu>
         </MainMenu>
         <footerBar></footerBar>
    </div>
</template>

<script>
    import Banner from '../../../components/bannder/Banner'
    import mainContent from '../../../components/content/mainContent'
    import MainMenu from '../../../components/mainmenu/MainMenu'
    import footerBar from '../../../components/content/footerBar'
    import NoData from '../../../components/nodata/NoData'
    export default {
        name: "EventsList",
        data(){
          return{
            uid: this.$route.query.uid,
            name: this.$route.query.name,
            list: [],
            flag:false,//是否显示暂无数据，默认不显示
          }
        },
        components:{
          Banner,
          mainContent,
          MainMenu,
          footerBar,
          NoData
        },
        created(){
        },

        mounted() {
          this.getData();
        },

        methods:{
          CheckDetail(id){
            let that = this;
            console.log('查看详情！');
            that.$router.push({path: '/event_detail', query:{id:id}});
          },

          CheckGuiji(id){
            let that = this;
            console.log('你点击了查看轨迹！');
            that.$router.push({path:'/guiji', query: {id: id, uid: that.uid}});
          },

          getData(){
            let that = this;
            that.$http.get("api/GriderPcApi/getVisitList?id="+that.uid, null, r=>{
              console.log(r);
              that.list = r.data;
              if (r.data.length==0){
                that.flag=true;
              }

            })
          }

        }
    }
</script>

<style scoped>
  .event_detail{
    height: 700px;
    width: 100%;
    box-sizing: border-box;
    padding-top: 60px;
  }
  .event_detail_list{
    height: 100%;
    width: 100%;
    overflow-y: scroll;
    padding-left: 5px;
    padding-right: 5px;
    /*display: flex;*/
    /*flex-direction: column;*/
  }
  .titles{
    height: 80px;
    width: 100%;
    box-sizing: border-box;
    padding-left: 60px;
    padding-right: 60px;
    display: flex;
    align-items: center;

  }
  .titles_left{
    flex: 1.8;
  }
  .title_desc{
    font-size: 28px;
    color: black;
    font-family: 微软雅黑;
    font-weight: bold;
    margin-right: 40px;
  }
  .titles_right{
    flex: 1.1;
  }
  .list_step{
    height: 80px;
    width: 100%;
    display: flex;
  }
  .step_left{
    flex: 1.8;
    color: black;
    font-size: 22px;
    display: flex;
    align-items: center;
  }
  .grid_name{
    display: block;
    width: 128px;
    padding-left: 2px;
  }
  .event{
    display: block;
    width: 154px;
    padding-left: 12px;
  }
  .content{
    padding-left: 4px;
  }




  .step_right{
    flex: 1.1;
    color: black;
    font-size: 22px;
    display: flex;
    align-items: center;
  }
  .status{
    display: block;
    width: 130px;
    margin-right: 27px;
  }
  .guiji{
    display: block;
    width: 155px;
  }
  .check_guiji{
    width: 120px;
    height: 38px;
    line-height: 38px;
    background: #21bd7e;
    color: white;
    border-radius: 8px;
    text-align: center;
  }



  .list_step:nth-child(odd){
    box-sizing: border-box;
    padding-left: 60px;
    padding-right: 60px;
    background: #ffffff;
  }
  .list_step:nth-child(even){
    padding-left: 60px;
    padding-right: 60px;
    background: #f8f8f8;
  }



  .yes{
    color: #29be74;
    padding-left: 24px;
  }
  .no{
    color: #ff3b30;
    padding-left: 24px;
  }




</style>
